package wikitools.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import wikitools.model.Note;
import wikitools.model.TextBase;
import wikitools.model.TextBaseFactory;
import wikitools.util.XMLUtil;

public class CreateNote extends HttpServlet {


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String cont = request.getParameter("content");
        Note note = new Note(cont);
        TextBase db = TextBaseFactory.getTextBase();
        db.createNote(note);
        
        response.setStatus(201); //resource created
        ServletUtil.writeXML(XMLUtil.toXML(note), response);
        
    }
    
    

}
